Run sub on main thread from separate thread [VB.NET|SerialPort]

Posted by Steven on Stack Overflow See other posts from Stack Overflow or by Steven
Published on 2010-12-31T00:50:53Z Indexed on 2010/12/31 0:53 UTC
Read the original article Hit count: 173

I'm reading data from a serial port, but the DataReceived event of SerialPort is handled on it's own thread. I want to handle this on the main thread, but simply declaring an event and raising it still results in it being processed on the SerialPort thread. I'm assuming I need to declare a delegate I can call, but I don't see how that would work.

For example, I want to call Sub HandleDataReceived() on the main thread from the DataReceived thread, having HandleDataReceived() run on the main thread. How would I do this?

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about serial-port